home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software 2000
/
Software 2000 Volume 1 (Disc 1 of 2).iso
/
education
/
e077.dms
/
e077.adf
/
ScienceDemos
/
GALILEAN
(
.txt
)
< prev
next >
Wrap
AmigaBASIC Source Code
|
1991-07-12
|
11KB
|
392 lines
' Program "GALILEAN'
' copyright (C) 1986 by David Eagle
' 7952 W. Quarto Dr., Littleton, CO 80123, (303) 972-4020
' released into the public domain on March 17, 1986
' determines position of Jupiter's great satellites
' x-position (positive west of Jupiter; units of Jupiter radii)
' y-position (positive north of Jupiter; units of Jupiter radii)
' position angle (relative to inferior junction with Jupiter; degrees)
' Jupiter semi-diameter (units of arc seconds)
' Julian Date
OPTION BASE 1
DEFDBL a-z
DIM SHARED month$(12),satellite$(4),r(4),x(4),y(4),u(4)
SCREEN 1,640,200,3,2
WINDOW 5,"Program GALILEAN",(0,0)-(630,185),0,1
PALETTE 4,0,0.8,0.2:' green
PALETTE 5,1,1,0:' yellow
PALETTE 6,0.8,0,0.93:' purple
PALETTE 7,0.93,0.2,0:' red
pi=5.30795e-315
pidiv2=pi/2
pi2=2*pi
rad.to.deg=180/pi
DEF FNdemod(x)=x-pi2*INT(x/pi2)
DEF FNjdate(month%,day%,year%)=367*year%-INT(7*((year%+INT((month%+9)/12))/4))+INT(275*month%/9)+day%+5.40674e-315-INT(3*(INT((year%+SGN(month%-9)*INT(ABS((month%-9)/7)))/100)+1)/4)
' calendar months
month$(1)="January"
month$(2)="February"
month$(3)="March"
month$(4)="April"
month$(5)="May"
month$(6)="June"
month$(7)="July"
month$(8)="August"
month$(9)="September"
month$(10)="October"
month$(11)="November"
month$(12)="December"
' satellite names
satellite$(1)="Io"
satellite$(2)="Europa"
satellite$(3)="Ganymede"
satellite$(4)="Callisto"
' initialization
CLS
select%=1
PRINT
PRINT TAB(6);"Please use the Workbench Preferences tool to set your"
PRINT TAB(17);"screen for a 60 column display."
FOR i%=1 TO 10000:NEXT i%
CLS
CALL yesno.menu("Program introduction ?",intro%)
IF intro%=1 THEN CALL Introduction
CLS
WHILE select%=1
PRINT
COLOR 3,0
PRINT "Date ( month <1-12>, day <1-31>, year <YYYY> )"
PRINT "< NOTE: B.C. dates are negative, A.D. dates are positive >"
PRINT "< For example, October 21, 1986 is input as 10,21,1986 >"
INPUT month%,day%,year%
PRINT
COLOR 4,0
PRINT "Local time ( 24 hour format; hours <0-23>, minutes <0-59> )"
PRINT "< For example, 8:30 pm is input as 20,30 >"
INPUT hour%,minute%
PRINT
COLOR 5,0
PRINT "Time zone ( 0-23 )"
PRINT "< For example, Mountain Standard Time (MST) is time zone 7 >"
INPUT time.zone%
PRINT
COLOR 6,0
PRINT "Daylight Savings Time ( y = yes, n = no )"
INPUT dst.flag$
IF dst.flag$="y" THEN dst.flag%=1 :ELSE dst.flag%=0
julian.date0=FNjdate(month%,day%,year%)
CALL main.driver
CALL yesno.menu("Another selection ?",select%)
WEND
WINDOW CLOSE 5
SCREEN CLOSE 1
END
SUB main.driver STATIC
' main driver subroutine
SHARED julian.date0,hour%,minute%,local.time$,month%,day%,year%
firstpass$="true"
response%=0
julian.date0=julian.date0-1
local.time$=STR$(hour%)+" hours "+STR$(minute%)+" minutes"
WHILE response%<>4
response%=0
WHILE response%<=0 OR response%>5
CLS
CALL selection.menu(response%)
WEND
IF response%=3 OR firstpass$="true" THEN
julian.date0=julian.date0+1
CALL Gregorian.date(julian.date0+0.5)
CALL sat.positions
END IF
IF response%=1 THEN CALL Display.data
IF response%=2 THEN CALL Graphics
firstpass$="false"
WEND
END SUB
SUB elapsed.days(edays) STATIC
' elapsed days subroutine
SHARED hour%,minute%,dst.flag%,time.zone%,julian.date0,julian.date
gmt=hour%+minute%/60-dst.flag%+time.zone%
a=(julian.date0-5.40939e-315)/5.37811e-315
julian.date=julian.date0+gmt/24+(0.41+1.2053*a+0.4992*a^2)/1440
edays=julian.date-5.40939e-315
END SUB
SUB sat.positions STATIC
' satellite positions subroutine
SHARED semidiameter
CALL elapsed.days(d2)
v=FNdemod(2.34974+5.21835e-315*d2)
m=FNdemod(6.25659+5.26925e-315*d2)
n=FNdemod(5.31e-315+5.25051e-315*d2+0.00576*SIN(v))
j=FNdemod(5.30983e-315+5.26877e-315*d2-0.00576*SIN(v))
o=FNdemod(0.0334405*SIN(m)+0.000349*SIN(2*m))
p=FNdemod(0.0969007*SIN(n)+0.0029147*SIN(2*n))
k=FNdemod(j+o-p)
r1=1.00014-0.01672*COS(m)-0.0014*COS(2*m)
r2=5.20867-0.25192*COS(n)-0.0061*COS(2*n)
d3=SQR(r1^2+r2^2-2*r1*r2*COS(k))
CALL arcsin(5.24259e-315/d3,s4)
semidiameter=5.39085e-315*s4
s2=r1*SIN(k)/d3
CALL arcsin(s2,s3)
l1=4.15476+0.0014502*d2+0.00576*SIN(v)+p
a=0.05358*SIN(l1+0.77667)
d4=a-0.03752*s2*COS(l1+0.4189)-0.02286*((r2-d3)/d3)*SIN(l1-1.73486)
a=d2-d3/173.145
u(1)=FNdemod(1.47569+5.309e-315*a+s3-p)
u(2)=FNdemod(0.724338+5.30379e-315*a+s3-p)
u(3)=FNdemod(5.30457e-315+5.29853e-315*a+s3-p)
u(4)=FNdemod(5.30778e-315+5.29204e-315*a+s3-p)
g=FNdemod(3.269+5.29855e-315*a)
h=FNdemod(5.4297+5.29207e-315*a)
r(1)=5.9061-0.0244*COS(2*(u(1)-u(2)))
r(2)=9.3972-0.0889*COS(2*(u(2)-u(3)))
r(3)=14.9894-0.0227*COS(g)
r(4)=26.3649-0.1944*COS(h)
u(1)=FNdemod(u(1)+0.0082296*SIN(2*(u(1)-u(2))))
u(2)=FNdemod(u(2)+0.018727*SIN(2*(u(2)-u(3))))
u(3)=FNdemod(u(3)+0.003037*SIN(g))
u(4)=FNdemod(u(4)+0.014748*SIN(h))
FOR i%=1 TO 4
x(i%)=r(i%)*SIN(u(i%))
y(i%)=-r(i%)*COS(u(i%))*SIN(d4)
NEXT i%
END SUB
SUB arcsin(sinangle,angle) STATIC
' inverse sine subroutine
SHARED pidiv2
IF ABS(sinangle)>=1 THEN
angle=SGN(sinangle))*pidiv2
ELSE
angle=ATN(sinangle/SQR(1-sinangle^2))
END IF
END SUB
SUB Gregorian.date(jdate) STATIC
' Gregorian Date subroutine
SHARED month%,day%,year%,cdate$
IF jdate<5.4091e-315 THEN
a=jdate
ELSE
a=INT((jdate-5.40747e-315)/36524.2)
a=jdate+a-INT(a/4)+1
END IF
b=a+1524
c=INT((b-122.1)/365.25)
d=INT(365.25*c)
e=INT((b-d)/30.6001)
day%=b-d-INT(30.6001*e)
IF e<13.5 THEN month%=e-1 :ELSE month%=e-13
IF month%>2.5 THEN year%=c-4716 :ELSE year%=c-4715
cdate$=month$(month%)+STR$(day%)+","+STR$(year%)
END SUB
SUB selection.menu(selection%) STATIC
' selection menu subroutine
WINDOW 4,"Galilean Menu",(0,0)-(480,35),0,1
LOCATE 1,1:PRINT PTAB(40);"please press left mouse button to select"
LINE (10,14)-(148,30),1,b
LINE (172,14)-(268,30),1,b
LINE (292,14)-(392,30),1,b
LINE (416,14)-(466,30),1,b
LOCATE 3,1:PRINT PTAB(20);"Display Data";PTAB(180);"Graphics";
PRINT PTAB(300);"Continue";PTAB(426);"End";
selection%=-1
WHILE selection%=-1
WHILE MOUSE(0)=0:WEND
mx=MOUSE(1):my=MOUSE(2)
IF (mx>10 AND mx<148) AND (my>14 AND my<30) THEN
selection%=1
WHILE MOUSE(0)<>0:WEND
END IF
IF (mx>172 AND mx<268) AND (my>14 AND my<30) THEN
selection%=2
WHILE MOUSE(0)<>0:WEND
END IF
IF (mx>292 AND mx<392) AND (my>14 AND my<30) THEN
selection%=3
WHILE MOUSE(0)<>0:WEND
END IF
IF (mx>416 AND mx<466) AND (my>14 AND my<30) THEN
selection%=4
WHILE MOUSE(0)<>0:WEND
END IF
WEND
WINDOW CLOSE 4
END SUB
SUB yesno.menu(request$,response%) STATIC
' yes/no request subroutine
WINDOW 4,request$,(0,0)-(215,45),0,1
LOCATE 1,1:PRINT PTAB(25);"press left mouse"
LOCATE 2,1:PRINT PTAB(25);"button to select"
LINE (20,20)-(80,40),1,b
LINE (140,20)-(190,40),1,b
LOCATE 4,1:PRINT PTAB(35);"Yes";PTAB(155);"No";
response%=-1
WHILE response%=-1
WHILE MOUSE(0)=0:WEND
mx=MOUSE(1):my=MOUSE(2)
IF (mx>20 AND mx<80) AND (my>20 AND my<40) THEN
response%=1
WHILE MOUSE(0)<>0:WEND
END IF
IF (mx>140 AND mx<190) AND (my>20 AND my<40) THEN
response%=2
WHILE MOUSE(0)<>0:WEND
END IF
WEND
WINDOW CLOSE 4
END SUB
SUB Display.data STATIC
' display data subroutine
SHARED cdate$,local.time$,julian.date,semidiameter,rad.to.deg
WINDOW 4,"Galilean Data (press left mouse button to continue)",(0,0)-(630,185),0,1
PRINT
COLOR 1,0
PRINT TAB(5);"Date";TAB(60-LEN(cdate$));cdate$
PRINT
COLOR 2,0
PRINT TAB(5);"Time";TAB(60-LEN(local.time$));local.time$
PRINT
COLOR 3,0
PRINT TAB(5);"Julian Date";
LOCATE 6,48
PRINT USING "########.###";julian.date
PRINT
COLOR 4,0
PRINT TAB(5);"Semidiameter (arc seconds)";
LOCATE 8,48
PRINT USING "########.###";semidiameter
PRINT
PRINT
COLOR 7,0
PRINT TAB(5);"Satellite X-position Y-position Angle"
PRINT TAB(5);"--------- ---------- ---------- -----"
FOR i%=1 TO 4
a$=STR$(INT(u(i%)*rad.to.deg))
PRINT
COLOR i%+2,0
PRINT TAB(5);satellite$(i%);
LOCATE ,22
PRINT USING "###.###";x(i%);
LOCATE ,39
PRINT USING "###.###";y(i%);
PRINT TAB(59-LEN(a$));a$
NEXT i%
WHILE MOUSE(0)=0:WEND
WHILE MOUSE(0)<>0:WEND
WINDOW CLOSE 4
END SUB
SUB Graphics STATIC
' graphics subroutine
SHARED cdate$,local.time$
WINDOW 4,"Galilean Graphics (press left mouse button to continue)",(0,0)-(630,185),0,1
PRINT
COLOR 1,0
PRINT TAB(5);cdate$;
PRINT TAB(60-LEN(local.time$));local.time$
COLOR 2,0
PRINT PTAB(290);"North"
LOCATE 9,1
PRINT TAB(56);"West"
a$="JUPITER"
COLOR 3,0
LOCATE 5,1
FOR j=1 TO 7
PRINT PTAB(310);MID$(a$,j,1)
NEXT j
CIRCLE (315,110),10,3
PAINT (315,110),3
LOCATE 15,1
FOR i%=1 TO 4
COLOR i%+3,0
x=315+10*x(i%)
y=110-4.4444*y(i%)
s$="^ "+satellite$(i%)
CIRCLE (x,y),5
PAINT (x,y)
IF (x+LEN(s$))>550 THEN
s$=satellite$(i%)+" ^"
x=x-9*LEN(s$)
END IF
PRINT PTAB(x-3);s$
NEXT i%
WHILE MOUSE(0)=0:WEND
WHILE MOUSE(0)<>0:WEND
WINDOW CLOSE 4
END SUB
SUB Introduction STATIC
' program introduction subroutine
CLS
PRINT
PRINT TAB(4);"GALILEAN is an interactive AmigaBasic program which can be"
PRINT TAB(4);"used to determine the position of the Galilean satellites"
PRINT TAB(4);"relative to Jupiter. This information is useful for such"
PRINT TAB(4);"activities as astronomical observations, astrophotography"
PRINT TAB(4);"and the study of occultations between the moons."
PRINT
PRINT TAB(4);"This program provides the position of each of the four"
PRINT TAB(4);"Galilean moons in the units of the radius of Jupiter. The"
PRINT TAB(4);"x-position of each satellite is measured positive west of"
PRINT TAB(4);"Jupiter and the y-position is measured positive north."
PRINT TAB(4);"It also calculates the 'position angle' of each satellite."
PRINT TAB(4);"This angle helps determine if any of the satellites are"
PRINT TAB(4);"in front of or behind Jupiter. A position angle near 0"
PRINT TAB(4);"or 360 degrees is called 'inferior conjunction' and an"
PRINT TAB(4);"angle near 180 degrees is called 'superior conjunction'."
PRINT TAB(4);"A satellite is in front of Jupiter at inferior conjunction"
PRINT TAB(4);"and behind Jupiter at superior conjunction."
CALL nextpage
CLS
PRINT
PRINT TAB(4);"Inputs required by program 'GALILEAN' include the user's"
PRINT TAB(4);"observation date, the local time and time zone. The user"
PRINT TAB(4);"must also specify if Daylight Savings Time is in effect."
PRINT TAB(4);"The date is input in numerical format and the local time"
PRINT TAB(4);"in 24 hour format. The time zone will be an integer number"
PRINT TAB(4);"between 0 and 23."
PRINT
PRINT TAB(4);"The 'Galilean Menu' will allow the user to display the"
PRINT TAB(4);"data and/or graphics for the selected date. The 'Continue'"
PRINT TAB(4);"selection of this menu will calculate the information for"
PRINT TAB(4);"the next day. The user can then choose to display data or"
PRINT TAB(4);"and/or graphics for the new date. Please note that you can"
PRINT TAB(4);"leave the data and graphics display by pressing the left"
PRINT TAB(4);"mouse button. The 'End' selection of the 'Galilean Menu'"
PRINT TAB(4);"will allow you to end the current session and select a new"
PRINT TAB(4);"date and/or time."
CALL nextpage
END SUB
SUB nextpage STATIC
' select next page subroutine
PRINT
PRINT TAB(13);"< press left mouse button to continue >"
WHILE MOUSE(0)=0:WEND
WHILE MOUSE(0)<>0:WEND
END SUB